factor by grouping